﻿using ConsoleApp4.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    public class DbInit:System.Data.Entity.DropCreateDatabaseIfModelChanges<Admin3000DbContext>
    {
        protected override void Seed(Admin3000DbContext context)
        {
            //context.Users.Add(new Entity.Users
            //{
            //    UserName = "admin",
            //    Password = "123",
            //    IsActived = true,
            //    IsDeleted = false,
            //    CreatedTime = DateTime.Now,
            //    UpdatedTime = DateTime.Now
            //});
            var brand1 = new Brands
            {
                BrandName = "苹果"
            };
            var brand2 = new Brands
            {
                BrandName = "梨子"
            };
            context.Brands.Add(brand1);
            context.Brands.Add(brand2);
            context.SaveChanges();
            var prod1 = new Product
            {
                ProductName = "苹果X",
                ShortDesc = "好用的东东",
                DetailsDesc = "苹果乔布斯创立的公司",
                BrandsId = brand1.Id
            };
            context.Products.Add(prod1);
            context.SaveChanges();
            base.Seed(context);
        }
    }
}
